<script setup lang="ts">
import type { VxeTableGridOptions } from '#/adapter/vxe-table';

import { Page } from '@vben/common-ui';

import { useVbenVxeGrid } from '#/adapter/vxe-table';
import { getReworkDocPagedListApi } from '#/api/rework/reworkDoc';

import { useColumns, useSearchSchema } from './data';

const [Grid] = useVbenVxeGrid({
  formOptions: {
    collapsed: false,
    fieldMappingTime: [['rangeDate', ['startTime', 'endTime']]],
    schema: useSearchSchema(),
    // 控制表单是否显示折叠按钮
    showCollapseButton: true,
    submitOnEnter: false,
    wrapperClass: 'grid-cols-3',
  },
  gridOptions: {
    columns: useColumns(),
    border: true,
    stripe: true,
    pagerConfig: {},
    proxyConfig: {
      ajax: {
        query: async ({ page }, formValues) => {
          return await getReworkDocPagedListApi({
            pageNumber: page.currentPage,
            pageSize: page.pageSize,
            ...formValues,
          });
        },
      },
    },
  } as VxeTableGridOptions,
});
</script>

<template>
  <Page auto-content-height>
    <Grid />
  </Page>
</template>
